<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">  
  <title>我的消息 - {:cms('title')}</title>
{include file="app/template/pc/default_pc/home_header.html"}
<div class="layui-body" style="padding: 20px;overflow: auto;">
<form class="layui-form" action="">
<table class="layui-table">
  <colgroup>
    <col width="100">
    <col width="500">
    <col width="100">
    <col>
  </colgroup>
  <thead>
    <tr>
      <th>用户</th>
      <th>内容</th>
      <th>操作</th>
    </tr> 
  </thead>
  <tbody>
    <tr>
      <td><input type="number" name="userid"  MIN="1" value=""  placeholder="用户的UID" autocomplete="off" lay-verify="required" class="layui-input"></td>
      <td><input type="text" name="content" value=""  placeholder="请输入内容" autocomplete="off" lay-verify="required" class="layui-input"></td>
      <td><button class="layui-btn layui-btn-warm" lay-submit lay-filter="set-add">发送消息</button></td>
    </tr>
  </tbody>
</table>
</form>
<hr style="padding:10px; background-color: #fff">
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
  <ul class="layui-tab-title">
    <a href="{:url('index/home/xiaoxi', array('id'=>1))}"><li {if condition="input('id') eq 1"}class="layui-this"{/if}>未读消息<span class="layui-badge">{:fun_st('xiaoxi',array('userid'=>session('userid'),'open'=>1))}</span></li></a>
    <a href="{:url('index/home/xiaoxi', array('id'=>0))}"><li {if condition="input('id') eq 0"}class="layui-this"{/if}>已读消息</li></a>
  </ul>
</div> 
<div style="overflow: auto;">
<table class="layui-table biaoge" lay-size="lg">
  <colgroup>
    <col width="100">
    <col width="500">
    <col width="100">
    <col width="100">
    <col>
  </colgroup>
  <thead>
    <tr>
      <th>用户</th>
      <th>标题</th>
      <th>时间</th>
      <th>操作</th>
    </tr> 
  </thead>
  <tbody>
{volist name=":fun_s('xiaoxi',array('open'=>input('id'),'model'=>0,'model'=>0,'userid'=>0,'uid'=>0),'id desc','200',1)" id="vo"}
    <tr>
      <td>系统消息</td>
      <td>{:htmltext($vo['content'])}</td>
      <td>{$vo.time|timeinfo}</td>
      <td></td>
    </tr>
{/volist}
  	
{volist name=":fun_s('xiaoxi',array('open'=>input('id'),'userid'=>session('userid')),'id desc','10,false',0)" id="vo"}
    <tr>
      <td>{if condition="$vo['uid'] eq '0'"}系统消息{else /}
      <a href="*URL*/uid_{:fun_sc_p('member', array('userid'=>$vo['uid']), 'userid')}.html" target="_blank">{:fun_sc_p('member', array('userid'=>$vo['uid']), 'username')}【UID:{:fun_sc_p('member', array('userid'=>$vo['uid']), 'userid')}】</a>
      {/if}
      </td>
      <td>
        {if condition="$vo['model'] eq '0'"}
        {$vo.content}
        {else /}
      	<a href="*URL*/s_{:m($vo['model'])}_{$vo.tid}.html" target="_blank">{:fun_sc_p(m($vo['model']), array('id'=>$vo['tid']), 'title')}</a>
      	{/if}
      </td>
      <td>{$vo.time|timeinfo}</td>
      <td><a href="javascript:;"  class="layui-btn ayui-btn-xs biaoji" ids="{$vo.id}">{if condition="$vo['open'] eq '1'"}标记已读{else}彻底删除{/if}</a></td>
    </tr>
{/volist}
  </tbody>
</table>
</div> 
<div class="pages">
{:fun_s('xiaoxi',array('open'=>1,'userid'=>session('userid')),'id desc','10,false',0)->render()}
<div>
</div>
<!--系统预留插件钩子请保消息页面-->
{:h('homexiaoxipc')}
{include file="app/template/pc/default_pc/home_footer.html"}
<script>
layui.use('form',function(){
  var form = layui.form
  ,jq = layui.jquery;
  
  jq('.biaoji').click(function(){
    var ids = jq(this).attr('ids');
      loading = layer.load(2, {
        shade: [0.2,'#000']
      });
      jq.getJSON('{:url("api/api/xiaoxi", array('id'=>input('id')))}?ids='+ids, function(data) {
        if(data.code == 200){
          layer.close(loading);
          layer.msg(data.msg, {icon: 1, time: 1000}, function(){
            location.reload();
          });
        }else{
          layer.close(loading);
          layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
        }
      });
  });
  
  //发送
  form.on('submit(set-add)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('{:url("api/api/xiaoxiadd")}',param,function(data){
      if(data.code == 1){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          //location.reload();
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
})
</script>